package com.fsp.blog.admin.controller;

import com.fsp.blog.admin.pojo.Permission;
import com.fsp.blog.admin.service.PermissionService;
import com.fsp.blog.admin.vo.Result;
import com.fsp.blog.admin.vo.params.PageParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author fushengping
 * @className AdminController
 * @description
 * @date 2021/11/23 23:17
 */
@RestController
@RequestMapping("/admin")
public class AdminController {

    @Autowired
    private PermissionService permissionService;

    /**
     * 权限信息分页
     * @param pageParam
     * @return
     */
    @PostMapping("/permission/permissionList")
    public Result permissionList(@RequestBody PageParam pageParam) {
        return permissionService.listPermission(pageParam);
    }

    /**
     * 权限添加
     * @param permission
     * @return
     */
    @PostMapping("permission/add")
    public Result add(@RequestBody Permission permission){
        return permissionService.add(permission);
    }

    /**
     * 权限信息修改
     * @param permission
     * @return
     */
    @PostMapping("permission/update")
    public Result update(@RequestBody Permission permission){
        return permissionService.update(permission);
    }

    /**
     * 权限信息删除
     * @param id
     * @return
     */
    @GetMapping("permission/delete/{id}")
    public Result delete(@PathVariable("id") Long id){
        return permissionService.delete(id);
    }
}
